perm filename 106A12[1,RWF] blob
sn#745999 filedate 1984-03-01 generic text, type C, neo UTF8
COMMENT ā VALID 00004 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 A Final Project
C00009 00003 Final Project
C00011 00004 CS 106 Final Project
C00013 ENDMK
Cā;
A Final Project
Western Movies
Your problem is to construct and run a program which writes scenarios (outlines
of the action) for western-style movies. The western film is a ritual art form,
with detailed conventions for behavior. Here is a sample:
Sheriff rides out of town.
Bad Guy rides into town.
Bad Guy robs bank.
Bad Guy rides out of town.
Fadeout. Time passes.
Good Guy rides into town.
Bad Guy walks into saloon.
Bad Guy drinks.
Good Guy walks into saloon.
Good Guy drinks.
Bad Guy drinks.
Bad Guy drinks.
Bad Guy hits Good Guy.
Good Guy hits Bad Guy.
Good Guy knocks Bad Guy down.
Fadeout. Time passes.
Good Guy rides into town.
Bad Guy walks out of saloon.
Bad Guy shoots.
Bad Guy kills Good Guy's friend.
Good Guy shoots.
Good Guy kills Bad Guy.
Good Guy rides out of town.
The End.
In your scenario, you may draw upon the following cast of characters:
Sheriff
Good Guy
Bad Guy
Good Guy's friends (As many as desired)
Bad Guy's friends (As many as desired)
Bystanders (As many as desired)
(Others as desired)
The following actions or types of action are sufficient to construct interesting
scenarios, although one could expand the list if he/she chose:
X rides (into/out of) town.
X walks (into/out of) saloon.
X drinks.
Bad Guy (robs bank/steals cattle).
Sheriff (arrests/releases) X.
X hits Y.
X knocks Y down.
X shoots.
X kills Y.
Bystanders run for cover.
Fadeout. Time passes.
The End.
(Others as desired).
In the name of consistency, you should observe some of the basic rules about place,
time, etc. Each character can only be in one place at a time, say one of the
following:
in street
out of town
saloon
jail
dead
not yet known
(others)
In addition, there are some important aesthetic conditions:
Fistfights occur only in saloon.
Gunfights only in the street.
Good Guy never strikes or shoots first.
Three drinks and you're drunk.
Drunks can't knock anyone down.
Drunks can't shoot straight.
The Bad Guy loses in the end.
Your friends are always around when you need them.
(Others)
Also, some essential logical conditions:
You can't kill (or hit or arrest) someone who isn't there.
Dead men can't do anything.
You can't arrest someone unless there has been a crime.
etc.
Requirements:
Your program should produce at least three scenarios of reasonable size. The
scenarios should make logical sense, i.e. don't have X kill Y and then have
Y ride out of town. Turn in your program listing and the printout of three
scenarios. Style and documentation, as well as correctness, will (as always)
be criteria for grading.
Hints:
You will want to use random numbers in order to choose between possible actions.
To do this use the Pascal function _random_. _random(x)_ returns a real number
which has a random value between 0 and 1. The procedure call _SetRan(seed)_ gives
the _random_ function an initial seed to use in generating the random numbers
(this is so you won't always get the same sequence). If a particular event has
a probability _p_ of occuring then use:
U:=Random(x);
If U>p then Event; (*the event occurs*)
Bells and Whistles
If this isn't already hard enough for you, here are some suggestions about
possible features to add: Allow for more than one Good (Bad) Guy each having
different names, you could even say perhaps that Bad Guy Joe really hates
Bad Guy Greene, etc; Let places have unique names, i.e., ``Last Chance Saloon,''
``The Dutch Goose Saloon,'' etc. Then rather than ``X walks into Saloon'' you
would say ``X walks into the Dutch Goose.'' Good Guy and Bad Guy would of course
have to be in the _same_ saloon then in order to get into a fight. You could add
subplots (romances, humor, etc.), other locations (a deep canyon into which the
Bad Guy falls), other people (farmer's daughter, female gunfighters, drunks,
doctors, computer programmers), other types of actions...there are many other
features you could add, so let your imagination be your guide.
References:
``Shane,'' ``The Man Who Shot Liberty Valence,'' ``High Noon,'' ``The Gunfighter,''
``Destry Rides Again,'' ``Red River,'' ``Stagecoach,'' all movies with Roy Rogers,
Gene Autrey, Lash Larue, Tom Mix....
Final Project
Casinos in Las Vegas offer for the amusement of their guests an electronic draw
poker game. After putting a coin in the slot, the bettor is dealt five cards.
By pressing any subset of five buttons, he discards some of his cards, which
are then replaced from the pack.
The machine pays off for the resulting hand at these rates:
1 pair, Jacks or better: 1 coin
2 pair: 2 coins
3 of a kind: 3 coins
Straight: 4 coins
Flush: 5 coins
Full house: 9 coins
4 of a kind: 25 coins
Straight flush: 50 coins
Royal flush: 200 coins
Write a program to make discarding decisions for such a bettor. (E.g., with
AQJxx of unrelated suits, to keep QJ is best; payoff is at least 3x6/47 for
pairing Q or J.)
CS 106 Final Project
Biologists assert that the number of species in a habitat increases in a systematic
way with size of the habitat. By simulating the plant population of islands of
several sizes, estimate the effect of size on number of species. Each island
is a square array of plants. The contents are integers (the species). At each
time step, each plant has a certain chance to be replaced by a seedling from a
neighboring plant, and a chance to mutate to form a new species. Mutation rates
are usually small compared to replacement rates.
Your simulation might investigate how long it takes to reach an equilibrium number
of species; how populations vary among species; and particularly, how the
equilibrium number of species changes with habitat size and mutation rate.
Suggestions: let the unit of time be that in which a plant has a 50% chance of
being replaced. Reuse species numbers, and keep a running population count for
each. Investigate the conjecture that the number of species at equilibrium is
proportional to the square root of habitat size, and proportional to mutation
rate. Initialize with a single species, and also with each plant representing
a distinct species.